package cn.edu.stu.syllabus.library.detail;

import cn.edu.stu.syllabus.dao.BookEntryDao;
import cn.edu.stu.syllabus.repository.library.BookStarDataSource;
import cn.edu.stu.syllabus.repository.library.local.BookEntry;
import cn.edu.stu.syllabus.repository.library.local.BookStarLocalDataSource;
import cn.edu.stu.syllabus.di.qualifier.Local;
import cn.edu.stu.syllabus.di.scope.FragmentScoped;
import cn.edu.stu.syllabus.utils.GreenDaoUtils;
import dagger.Module;
import dagger.Provides;

/**
 * Created by liyujie on 2017/3/28.
 */

@Module
public class BookDetailPresenterModule {

    private final BookDetailContract.View mView;
    private final BookEntry mBookEntry;

    public BookDetailPresenterModule(BookDetailContract.View view, BookEntry bookEntry) {
        mView = view;
        mBookEntry = bookEntry;
    }

    @FragmentScoped
    @Provides
    public BookDetailContract.View provideView() {
        return mView;
    }

    @FragmentScoped
    @Provides
    public BookEntry provideBookEntry() {
        return mBookEntry;
    }

    @FragmentScoped
    @Provides
    BookEntryDao provideBookEntryDao() {
        return GreenDaoUtils.getInstance().getSession().getBookEntryDao();
    }

    @FragmentScoped
    @Provides
    @Local
    BookStarDataSource provideBookLocalDataSource(BookEntryDao bookEntryDao) {
        return new BookStarLocalDataSource(bookEntryDao);
    }
}
